project(chassis_ros)
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_PREFIX_PATH "/opt/ros/noetic")
set(CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/share/catkin/cmake")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -g -std=c++11 -O0 ")

#set(serial_driver "chassis_driver")
#add_subdirectory(serial_driver)

find_package(catkin REQUIRED COMPONENTS
        roscpp
        std_msgs
        std_srvs
        roslib
        nav_msgs
        tf
)

catkin_package()

include_directories(
        ${catkin_INCLUDE_DIRS}
        ${CMAKE_CURRENT_SOURCE_DIR}/src
        ${CMAKE_CURRENT_SOURCE_DIR}/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/unitree_sdk2/include/unitree/
        ${CMAKE_CURRENT_SOURCE_DIR}/unitree_sdk2/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/unitree_sdk2/thirdparty/include/ddscxx/
        ${CMAKE_CURRENT_SOURCE_DIR}/unitree_sdk2/thirdparty/include/
)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src DIR_SRCS)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/unitree_sdk2/)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/unitree_sdk2/lib/x86_64/)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/unitree_sdk2/thirdparty/lib/x86_64)

add_executable(${PROJECT_NAME}_node ${DIR_SRCS})
#        src/chassis.cpp
#        src/chassis.h
#        src/main.cpp)
#target_link_libraries(${PROJECT_NAME}_node  ${catkin_LIBRARIES})
target_link_libraries(${PROJECT_NAME}_node PUBLIC unitree_sdk2 ddsc ddscxx pthread ${catkin_LIBRARIES})

#add_custom_command(
#        OUTPUT copy_lib
#        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/lib/* ${CATKIN_DEVEL_PREFIX}/lib
#)
#add_custom_target(COPY_CHASSIS_LIB ALL DEPENDS copy_lib ${PROJECT_NAME}_node)

#install(TARGETS ${PROJECT_NAME}_node
#        RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
#)
#
#install(FILES lib/lib${serial_driver}.so
#        DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
#)
#
#install(DIRECTORY launch
#        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
#)



